# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=flite
pkgver=2.1
pkgrel=2
pkgdesc="Small, fast speech synthesis engine (text-to-speech)"
url="http://www.speech.cs.cmu.edu/flite"
arch="all"
license="MIT"
makedepends="alsa-lib-dev"
subpackages="$pkgname-dev"
source="http://www.festvox.org/$pkgname/packed/$pkgname-$pkgver/$pkgname-$pkgver-release.tar.bz2
	fix-internal-linking.patch"
builddir="$srcdir/$pkgname-$pkgver-release"

build() {
	cd "$builddir"
	CFLAGS="$CFLAGS -fPIC" ./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--enable-shared \
		--localstatedir=/var \
		--with-audio=alsa
	# work around parallel build issue
	make -C include
	make -C src
	make -C lang
	make -C tools
	make -j1
}

package() {
	cd "$builddir"
	make install INSTALLBINDIR="$pkgdir"/usr/bin \
		INSTALLLIBDIR="$pkgdir"/usr/lib \
		INSTALLINCDIR="$pkgdir"/usr/include/flite
	# remove relative rpaths
	scanelf -R -r --fix "$pkgdir"
	mkdir -p "$pkgdir"/usr/lib/pkgconfig
	cat > "$pkgdir"/usr/lib/pkgconfig/flite.pc <<EOF
prefix=/usr
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib
includedir=\${prefix}/include

Name: flite
Description: a text to speech library
Requires:
Version: 2.1
Libs: -L\${libdir} -lflite -lflite_cmu_grapheme_lang -lflite_cmu_grapheme_lex -lflite_cmu_indic_lang -lflite_cmu_indic_lex -lflite_cmulex -lflite_cmu_time_awb -lflite_cmu_us_awb -lflite_cmu_us_kal16 -lflite_cmu_us_kal -lflite_cmu_us_rms -lflite_cmu_us_slt -lflite_usenglish
Libs.private: -lm
Cflags: -I\${includedir}/flite/
EOF
}

sha512sums="e9ef9ca4b6920178634d94bbe6e21a8b0ec471b010b07e6cc961ed2d120acb944c8e1d268fe26188f7dfe43fb7bd4bdff7fa53b2d2f12029d37e08d0316620d2  flite-2.1-release.tar.bz2
3794f7b6520ab11e5fd2e6e8dc2ce630f0bcb26ea42f94778e410c08f50e3b4c9c6388e60c15deb545df0d8a83f0299fc75766a606f040c13f68ae2f38b6a5df  fix-internal-linking.patch"
